import 'package:flutter/material.dart';
import 'package:flutter_one/components/detial_page.dart';

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.grey,
        centerTitle: true,
        title: const Text('首页'),
      ),
      body: Center(
        child: Column(
          children: [
            const Text('首页'),
            ElevatedButton(
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) => const DetialPage()),
                  );
                },
                child: const Text('去详情页：方式1')),
            ElevatedButton(
                onPressed: () {
                  Navigator.pushNamed(context, '/detail',
                      arguments: {'id': 1, 'name': '详情页22222'});
                },
                child: const Text('去详情页：方式2'))
          ],
        ),
      ),
    );
  }
}

class DetailPage {
  const DetailPage();
}
